package com.c.ctgproject.adapter.guang

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.recyclerview.widget.RecyclerView
import com.c.ctgproject.R
import com.c.ctgproject.base.BaseEmptyRecyclerViewAdapterV2
import com.c.ctgproject.entity.guang.BatteryInWarehouseEntity
import com.c.ctgproject.entity.guang.CarListEntity
import com.c.ctgproject.entity.guang.PowerBatteryOutEntity
import com.c.ctgproject.ui.collect.*
import com.c.ctgproject.utils.MyConstants
import com.c.ctgproject.utils.getGson
import com.c.ctgproject.utils.handlerNull
import com.c.ctgproject.utils.noDataHandler
import org.jetbrains.anko.startActivity
import org.jetbrains.anko.textColorResource

class BatteryOutWarehouseAdapter(private val context: Context, private val mList: List<PowerBatteryOutEntity.DataBean.ListBean>) : BaseEmptyRecyclerViewAdapterV2(context, mList) {
    override fun createViewHolder(parent: ViewGroup): RecyclerView.ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.item_battery_out_warehouse_list, parent, false)
        return MyViewHolder(view)
    }

    override fun handlerData(holder: RecyclerView.ViewHolder, position: Int) {
        if (holder is MyViewHolder) {
            val data = mList[position]



            holder.mUserNameTV.text = data.createPersonName.noDataHandler()
            holder.mTimeTV.text = data.createTime.noDataHandler()
            holder.mClientTV.text = data.customer.noDataHandler()
            holder.mCodeTV.text = data.bizNo.noDataHandler()
//
//
//            holder.mBottomRL.setOnClickListener {
//                holder.mBTN.performClick()
//            }
//            holder.mBTN.setOnClickListener {
//                //出库
//            }
            holder.mParentLL.setOnClickListener {
                //查看详情
                context.startActivity<PowerBatteryOutActivity>(MyConstants.ORDER_ID to data.outOrderId)

//                context.startActivity<BatteryDetailActivity>(MyConstants.ORDER_ID to data.orderId)
            }
        }
    }

    inner class MyViewHolder(view: View) : RecyclerView.ViewHolder(view) {
        val mUserNameTV: TextView = view.findViewById(R.id.mUserNameTV)
        val mClientTV: TextView = view.findViewById(R.id.mClientTV)
        val mTimeTV: TextView = view.findViewById(R.id.mTimeTV)
        val mCodeTV: TextView = view.findViewById(R.id.mCodeTV)
//        val mBottomRL: RelativeLayout = view.findViewById(R.id.mBottomRL)
//        val mBTN: Button = view.findViewById(R.id.mBTN)
        val mParentLL: LinearLayoutCompat = view.findViewById(R.id.mParentLL)

    }


}